<?php
// +----------------------------------------------------------------------
// | Powered By ThinkPHP 5.0.12
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://www.bojuwang.net All rights reserved.
// +----------------------------------------------------------------------
// | Date：2018-6
// +----------------------------------------------------------------------
// | Author: NanTao <260053530@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Config;
use \think\Db;
use \think\Controller;
use \think\Request;
class System extends AdminBasic
{
    public function index()
    {
        $list = Db::name('admin_ratio')->select();
        $this->assign('list',$list);
        return $this->fetch();
    }
    public function add()
    {
        if (request()->isPost()) {
            $data = input('param.');
            $res = Db::name('admin_ratio')->insert($data);
            if ($res) {
                json_msg(0,'添加成功');
            }
            else {
                json_msg(1,'添加失败');
            }
        }
        else {
            return $this->fetch();
        }
    }
    public function edit()
    {
        $id = input('param.id');
        if (request()->isPost()) {
            $data = input('param.');
            $res = Db::name('admin_ratio')->where('id',$id)->update($data);
            if ($res || $res == 0) {
                json_msg(0,'编辑成功');
            }
            else {
                json_msg(1,'编辑失败');
            }
        }
        else {
            $info = Db::name('admin_ratio')->where('id',$id)->find();
            $this->assign('info',$info);
            return $this->fetch();
        }
    }
    public function del()
    {
        $id = input('param.id');
        $result = Db::name('admin_ratio')->where('id',$id)->delete();
        if($result) {
            json_msg(0,'删除成功');
        }
        else {
            json_msg(1,'删除失败');
        }
    }
}